<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<link href="./css/common.css" rel="stylesheet"  />
<link href="../../css/buttons.css" rel="stylesheet"  />
<script type="text/javascript" src="../../js/util.js"></script>
<script type="text/javascript">
function addFileItem(){
	var fileItemContainer=document.getElementById("fileItemContainer");
	var span=document.createElement("span");
	span.innerHTML="<input type=\"file\" name=\"photo\" /><a href=\"javascript:void(0)\" onclick=\"deleteFileItem(this)\">删除</a><br/>";
	fileItemContainer.appendChild(span);
}
function deleteFileItem(linkItem){
	if(confirm("确认删除？")){
		linkItem.parentNode.parentNode.removeChild(linkItem.parentNode);
		var tipItem=document.getElementById("tipItem");
		tipItem.style.display="none";
	}
}
function showPic(picName){
	window.open("../../images/"+picName);
}
function removePic(){
	if(window.currentImageThume){
		var tipItem=document.getElementById("tipItem");
		if(confirm("确认删除？")){
			window.currentImageThume.parentNode.removeChild(window.currentImageThume);
			window.currentImageThume=null;
		}
		tipItem.style.left="-100000000px";
	}
}

function initAction(){
	var picConainer=document.getElementById("picConainer");
	var nodes=picConainer.childNodes;
	for(var i=0;i<nodes.length;i++){
		if(nodes[i].nodeType==1){//查找元素节点，实际上就是图片节点
			nodes[i].onmouseover=function(){
				showControlCt(this,true);
			};
			nodes[i].onmouseout=function(){
				showControlCt(this,false);
			};
		}
	}
	var tipItem=document.getElementById("tipItem");
	tipItem.onmouseover=function(){
		this.style.display="block";
	};
}
function showControlCt(obj,isShow){
	var tipItem=document.getElementById("tipItem");
	var size=$area(tipItem);
	if(isShow){
		var pos=$area(obj);
		window.currentImageThume=obj;
		tipItem.style.left=pos.x+3;
		tipItem.style.top=pos.y+3;
		tipItem.style.display="block";
	}
	else{
		tipItem.style.display="none";
	}
}

window.onload=function(){
	initAction();
};

function checkForm(frm){
	var address=frm['adddress'];
	var postcode=frm['postcode'];
	var mangername=frm['mangername'];
	var phone=frm['phone'];
	var fax=frm['fax'];
	var desc=frm['desc'];
	
	if(address.value.trim().length<1){
		alert("请输入地址！");
		address.select();
		return false;
	}
	if(!new FieldValidate(postcode).tminlen(6,"邮编")){
		return false;
	}
	if(!new FieldValidate(postcode).tmaxlen(6,"邮编")){
		return false;
	}
	if(!new FieldValidate(mangername).tminlen(1,"负责人")){
		return false;
	}
	if(!new FieldValidate(phone).tminlen(1,"电话")){
		return false;
	}
	if(!new FieldValidate(fax).tminlen(1,"传真")){
		return false;
	}
	if(!new FieldValidate(desc).tminlen(1,"简介")){
		return false;
	}
}
</script>
</head>
<body>
<div class="pic-tip-item" id="tipItem">
	<input type="button" value="删除" onclick="removePic()" />
	<input type="button" value="查看" />
</div>
<form action="#" method="post" onsubmit="return checkForm(this)">
<table cellpadding="0" cellspacing="1" border="0" width="100%">
	<tr class="th">
		<td colspan="2">资料维护</td>
	</tr>
	<tr class="tb">
		<td width="60">单位名称</td>
		<td><input type="text" name="copname" id="copname" /></td>
	</tr>
	<tr class="tb">
		<td width="60">站点名称</td>
		<td><input type="text" name="sitename" id="sitename" /></td>
	</tr>
	<tr class="tb">
		<td>地址</td>
		<td><input type="text" name="adddress" size="50" id="adddress" /></td>
	</tr>
	<tr class="tb">
		<td>邮政编码</td>
		<td><input type="text" name="postcode" id="postcode" /></td>
	</tr>
	<tr class="tb">
		<td>联系人</td>
		<td><input type="text" name="contactPerson" id="contactPerson" /></td>
	</tr>
	<tr class="tb">
		<td>电话</td>
		<td><input type="text" name="phone" id="phone" /></td>
	</tr>
	<tr class="tb">
		<td>传真</td>
		<td><input type="text" name="fax" id="fax" /></td>
	</tr>
	<tr class="tb">
		<td>电子邮件</td>
		<td><input type="text" name="email" id="email" /></td>
	</tr>
	<tr class="tb">
		<td>网址</td>
		<td><input type="text" name="email" id="email" /></td>
	</tr>
	<tr class="tb">
		<td>版权所有</td>
		<td><input type="text" name="copyright" id="copyright" /></td>
	</tr>
	<tr class="tb">
		<td>关于我们</td>
		<td><textarea name="aboutus" id="aboutus" cols="80" rows="10"></textarea></td>
	</tr>
	<tr class="tb">
		<td>备注</td>
		<td><textarea name="remark" id="remark" cols="80" rows="10"></textarea></td>
	</tr>
	<tr class="tf" >
		<td class="center" colspan="2">
			<input type="submit" value="" class="submit"/>
			<input type="reset" value="" class="reset"/>
		</td>
	</tr>
</table>
</form>
</body>
</html>